package main

import (
	"flag"
	"fmt"
	"ll_csv_con/ccore"
	"os"
)

//1、筛选功能，对指定的csv 指定的 列，做筛选
//2、合并分析，对（一对）指定的csv 指定的列做合并分析

var (
	csvpath *string
	target  *string
	key     *string
	icase   *string

	csv1path *string
	csv2path *string
	target1  *string
	target2  *string
)

func main() {

	//./main sx -csvpath=大掌柜6月充值明细-改.csv  -target=子游戏名 -key=ios
	sxCmd := flag.NewFlagSet("sx", flag.ExitOnError)
	// 定义命令行参数对应的变量，这三个变量都是指针类型
	csvpath = sxCmd.String("csvpath", "", "Input Your csvpath")
	target = sxCmd.String("target", "", "Input Your target")
	key = sxCmd.String("key", "", "Input Your key")
	icase = sxCmd.String("icase", "yes", "Input Your icase") //默认忽略大小写

	//./main hb -csv1path=大掌柜6月充值明细-改_new_sx.csv  -target1=平台订单号 -csv2path=skn_06.csv  -target2=平台订单号
	hbCmd := flag.NewFlagSet("hb", flag.ExitOnError)
	csv1path = hbCmd.String("csv1path", "", "Input Your csv1")
	csv2path = hbCmd.String("csv2path", "", "Input Your csv2")
	target1 = hbCmd.String("target1", "", "Input Your target1")
	target2 = hbCmd.String("target2", "", "Input Your target2")

	if len(os.Args) < 2 {
		fmt.Println("expected 'sx' or 'hb' subcommands")
		os.Exit(1)
	}

	flag.Parse()

	switch os.Args[1] {
	case "sx":
		//1、筛选功能，对指定的csv 指定的 列，做筛选
		sxCmd.Parse(os.Args[2:])
		fmt.Println("  csvpath:", *csvpath)
		fmt.Println("  target:", *target)
		fmt.Println("  key:", *key)
		fmt.Println("  icase:", *icase)
		ccore.Sx(*csvpath, *target, *key, *icase)
	case "hb":
		hbCmd.Parse(os.Args[2:])
		fmt.Println("  csv1path:", *csv1path)
		fmt.Println("  csv2path:", *csv2path)
		fmt.Println("  target1:", *target1)
		fmt.Println("  target2:", *target2)
		ccore.Hb(*csv1path, *csv2path, *target1, *target2)
	default:
		fmt.Println("expected 'sx' or 'hb' subcommands")
		os.Exit(1)
	}
}
